package com.example.sms;

import java.util.LinkedHashMap;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


public class Sms_list_adapter extends BaseAdapter {
    private LinkedHashMap<String, String> mData = new LinkedHashMap<String, String>();
    private String[] mKeys;
    public Sms_list_adapter(LinkedHashMap data){
        mData  = data;
        mKeys = mData.keySet().toArray(new String[data.size()]);
    }

    public int getCount() {
        return mData.size();
    }

    public Object getItem(int position) {
        return mData.get(mKeys[position]);
    }

    public long getItemId(int arg0) {
        return arg0;
    }

    public View getView(int pos, View convertView, ViewGroup parent) {
        String key = mKeys[pos];
        String Value = getItem(pos).toString();

        //do your view stuff here
        TextView message = (TextView)convertView.findViewById(R.id.body);
        TextView phone = (TextView)convertView.findViewById(R.id.address);
        
        message.setText(Value);
        phone.setText(Value);

        return convertView;
    }
}



/*public class Sms_list_adapter extends BaseAdapter {

	private Object _data;
    Context _c;
    
    Sms_list_adapter (Object data, Context c){
        _data = data;
        _c = c;
    }

/*    Sms_list_adapter (ArrayList<String> data, Context c){
        _data = data;
        _c = c;
    }

	public int getCount() {
        // TODO Auto-generated method stub
        return _data.size();
    }
   
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return _data.get(position);
    }

	public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }
    public View getView(int position, View convertView, ViewGroup parent) {
         if (convertView == null){
            LayoutInflater vi = (LayoutInflater)_c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = vi.inflate(R.layout.sms_list_item, null);
         }

           TextView message = (TextView)convertView.findViewById(R.id.body);
           TextView phone = (TextView)convertView.findViewById(R.id.address);
           //TextView name = (TextView)convertView.findViewById(R.id.address);
           
           //String pos = _data.;
           
           //message.setText(pos);
           //phone.setText(pos);
           //name.setText(MainActivity.name);
        return convertView;
}

	public int getCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}
	

}*/